﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Text;
using Newtonsoft.Json;

namespace CreateStandardJson
{
    class Program
    {
        static void Main(string[] args)
        {
            
            var RadioStreams = new ObservableCollection<RadioStream>{new RadioStream
                                                                         {
                                                                             Id = Guid.NewGuid(), StreamName = "WDR5", StreamUri = "http://www.wdr.de/wdrlive/media/wdr5.m3u", LastPlayed = DateTime.Now
                                                                         }, new RadioStream
                                                                                {
                                                                                    Id = Guid.NewGuid(), StreamName = "RA Alternative", StreamUri = "http://www.rockantenne.de/webradio/channels/alternative.m3u", LastPlayed = new DateTime(2011,01,01,01,01,01)
                                                                                }, new RadioStream
                                                                                       {
                                                                                           Id = Guid.NewGuid(), StreamName = "1LIVE", StreamUri = "http://www.wdr.de/wdrlive/media/einslive.m3u", LastPlayed = new DateTime(2010,01,01,01,01,01)
                                                                                       }};
            var Settings = new SettingsContainer
                               {
                                   LastPlayedStation = RadioStreams.First(),
                                   Volume = 50

                               };

            string rootpath = Environment.CurrentDirectory;

            using (FileStream fs = File.Open(rootpath+"\\streams.json", FileMode.CreateNew ))
            using (StreamWriter sw = new StreamWriter(fs))
            using (JsonWriter jw = new JsonTextWriter(sw))
            {
                jw.Formatting = Formatting.Indented;
                JsonSerializer serializer = new JsonSerializer();
                serializer.Serialize(jw, RadioStreams);
            }

            using (FileStream fs = File.Open(rootpath + "\\settings.json", FileMode.CreateNew))
            using (StreamWriter sw = new StreamWriter(fs))
            using (JsonWriter jw = new JsonTextWriter(sw))
            {
                jw.Formatting = Formatting.Indented;
                JsonSerializer serializer = new JsonSerializer();
                serializer.Serialize(jw, Settings);
            }

        }
    }

    public class RadioStream
    {
        #region Properties

        public string StreamName
        {
            get;
            set;
        }

        public string StreamUri
        {
            get;
            set;
        }

        public Guid Id
        { get; set; }

        public DateTime LastPlayed { get; set; }

        #endregion Properties
    }


    public class SettingsContainer
    {

        public int Volume { get; set; }
        public RadioStream LastPlayedStation { get; set; }

    }


}
